﻿
using MediaBrowserSL.RIA.Views;
using System;
using MediaBrowserSL.RIA.ViewModels;

namespace MediaBrowserSL.RIA.MvvmUtils.UI
{
    /// <summary>
    /// Player Movies 
    /// </summary>
    public class PlayerMoviesVisualizer : IPlayerMoviesVisualizer
    {
        private ChildWindowPlayer dlg;

        /// <summary>
        /// Show Player Movies 
        /// </summary>
        public void Show()
        {
            dlg = new ChildWindowPlayer();

            EventHandler handler = null;
            handler = delegate
            {
                ((ViewModelBase)dlg.DataContext).RequestClose -= handler;
                dlg.Close();
            };
            ((ViewModelBase)dlg.DataContext).RequestClose += handler;

            dlg.Show();
        }

        /// <summary>
        /// Set Size
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public void SetSize(double width, double height)
        {
            if (dlg != null)
            {
                dlg.SetValue(ChildWindowPlayer.WidthProperty, width);
                dlg.SetValue(ChildWindowPlayer.HeightProperty, height);
            }
        }
    }
}
